package exams;

/**
 * Created by pc on 2015/5/15.
 * 振幅不超过1的最长序列长度
 */
public class QuasiConstant {
    public int solution(int [] A){
        int maxLen = 0;
        for (int ele: A){
            int count = 0;

            for (int e : A) {
                if (e == ele || e == (ele + 1)) {
                    count++;
                }
            }
            if (count > maxLen){
                //record the new max length
                maxLen = count;
            }
        }
        return maxLen;
    }

    public static void main(String args[]){
        QuasiConstant qc = new QuasiConstant();
        System.out.println("max quasi constanct length is: " + qc.solution(new int[]{6, 10, 6, 7, 9, 11, 11, 10}));
    }
}
